package corej.course.exception;

import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;

public class TestException {
    public static void main(String[] args) {
        int i = Integer.parseInt(args[0]);
        System.out.println("main 1");
        ma(i);
        System.out.println("main 2");
    }

    @SuppressWarnings("hiding")
    static void ma(int i) {
        try {
            System.out.println("ma 1");
            mb(i);
            System.out.println("ma 2");
        } catch (FileNotFoundException e) {
            // System.out.println(e.getMessage());
            e.printStackTrace();
        } catch (EOFException e) {
            // System.out.println(e.getMessage());
            e.printStackTrace();
        } catch (IOException e) {
            // System.out.println(e.getMessage());
            e.printStackTrace();
        } catch (SQLException e) {
            // System.out.println(e.getMessage());
            e.printStackTrace();
        } catch (MyException e) {
            e.printStackTrace();
        } catch (Exception e) {
            // System.out.println(e.getMessage());
            e.printStackTrace();
        } finally {
            System.out.println("Run Finally");
        }

        System.out.println("ma 3");
    }

    static void mb(int i) throws FileNotFoundException, EOFException,
            SQLException, MyException {
        System.out.println("mb 1");
        mc(i);
        System.out.println("mb 2");
    }

    static void mc(int i) throws FileNotFoundException, EOFException,
            SQLException, MyException {
        System.out.println("mc 1");
        if (i == 0)
            throw new NullPointerException("��ָ���쳣");
        if (i == 1)
            throw new FileNotFoundException("�ļ�û�ҵ�");
        if (i == 2)
            throw new EOFException("�ļ��쳣��ֹ");
        if (i == 3)
            throw new SQLException("��ݿ��쳣");
        if (i == 4)
            throw new MyException("���Լ�������쳣���Ǻ�");
        System.out.println("mc 2");
    }
}

@SuppressWarnings("serial")
class MyException extends Exception {
    public MyException(String message) {
        super(message);
    }
}